%%%	======================================================================== %%%
%%% Coding: cp1251                                                           %%%
%%%                                                                          %%%
%%% xmpp.hrl  "Configuration xmpp protocol and library xmlns"                %%%
%%%                                                                          %%%
%%% Copyright (C) 2009 Mihailov Artem                                        %%%
%%%                                                                          %%%
%%% This program is free software: you can redistribute it and/or modify it  %%%
%%%	under the terms of the GNU General Public License as published by the    %%%
%%%	Free Software Foundation, either version 3 of the License, or (at your   %%%
%%%	option) any later version.                                               %%%
%%%                                                                          %%%
%%% This program is distributed in the hope that it will be useful, but      %%%
%%%	WITHOUT ANY WARRANTY; without even the implied warranty of               %%%
%%%	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General %%%
%%%	Public License for more details.                                         %%%
%%%                                                                          %%%
%%% You should have received a copy of the GNU General Public License along  %%%
%%%	with this program. If not, see <http://www.gnu.org/licenses/>.           %%%
%%% ======================================================================== %%%

-define(DEBUG(A,B),logs:debug(A,B)).
-define(ERROR(A,B),logs:error(A,B)).

-define(ERR_CON(A),inet:format_error(A)).
-define(ERR_FILE(A),file:format_error(A)).
-define(ERR_SSL(A),ssl:format_error(A)).

-define(DEFAULT_OPTIONS,[{connect_method,tcp},{auth_method,plain},{port,5222},
                         {host,""},{debug,[{debug,false},{write,false}]},
                         {error,[{error,false},{write,false}]},{cacertfile,[]},
                         {certfile,[]},{keyfile,[]}]).

%%% xmlns =====================================================================
-define(NS_ACTIVITY,										"http://jabber.org/protocol/activity").
-define(NS_ADDRESS,											"http://jabber.org/protocol/address").
-define(NS_ADMIN,												"http://jabber.org/protocol/admin").
-define(NS_ADMIN_ADD_USER, 						 	?NS_ADMIN++"#add-user").
-define(NS_ADMIN_DELETE_USER,           ?NS_ADMIN++"#delete-user").
-define(NS_ADMIN_DISABLE_USER,          ?NS_ADMIN++"#disable-user").
-define(NS_ADMIN_REENABLE_USER,         ?NS_ADMIN++"#reenable-user").
-define(NS_ADMIN_END_USER_SESSION,      ?NS_ADMIN++"#end-user-session").
-define(NS_ADMIN_GET_USER_PASSWORD,     ?NS_ADMIN++"#get-user-password").
-define(NS_ADMIN_CHANGE_USER_PASSWORD,  ?NS_ADMIN++"#change-user-password").
-define(NS_ADMIN_GET_USER_ROSTER,       ?NS_ADMIN++"#get-user-roster").
-define(NS_ADMIN_GET_USER_LASTLOGIN,    ?NS_ADMIN++"#get-user-lastlogin").
-define(NS_ADMIN_USER_STATS,            ?NS_ADMIN++"#user-stats").
-define(NS_ADMIN_EDIT_BLACKLIST,        ?NS_ADMIN++"#edit-blacklist").
-define(NS_ADMIN_EDIT_WHITELIST,        ?NS_ADMIN++"#edit-whitelist").
-define(NS_ADMIN_REGISTERED_USERS_NUM,  ?NS_ADMIN++"#get-registered-users-num").
-define(NS_ADMIN_DISABLED_USERS_NUM,    ?NS_ADMIN++"#get-disabled-users-num").
-define(NS_ADMIN_ONLINE_USERS_NUM,      ?NS_ADMIN++"#get-online-users-num").
-define(NS_ADMIN_ACTIVE_USERS_NUM,      ?NS_ADMIN++"#get-active-users-num").
-define(NS_ADMIN_IDLE_USERS_NUM,        ?NS_ADMIN++"#get-idle-users-num").
-define(NS_ADMIN_REGISTERED_USERS_LIST, ?NS_ADMIN++"#get-registered-users-list").
-define(NS_ADMIN_DISABLED_USERS_LIST,   ?NS_ADMIN++"#get-disabled-users-list").
-define(NS_ADMIN_ONLINE_USERS_LIST,     ?NS_ADMIN++"#get-online-users-list").
-define(NS_ADMIN_ACTIVE_USERS_LIST,     ?NS_ADMIN++"#get-active-users-list").
-define(NS_ADMIN_IDLE_USERS_LIST,       ?NS_ADMIN++"#get-idle-users-list").
-define(NS_ADMIN_ANNOUNCE,              ?NS_ADMIN++"#announce").
-define(NS_ADMIN_SET_MOTD,              ?NS_ADMIN++"#set-motd").
-define(NS_ADMIN_EDIT_MOTD,             ?NS_ADMIN++"#edit-motd").
-define(NS_ADMIN_DELETE_MOTD,           ?NS_ADMIN++"#delete-motd").
-define(NS_ADMIN_SET_WELCOME,           ?NS_ADMIN++"#set-welcome").
-define(NS_ADMIN_DELETE_WELCOME,        ?NS_ADMIN++"#delete-welcome").
-define(NS_ADMIN_EDIT_ADMIN,            ?NS_ADMIN++"#edit-admin").
-define(NS_ADMIN_RESTART,               ?NS_ADMIN++"#restart").
-define(NS_ADMIN_SHUTDOWN,              ?NS_ADMIN++"#shutdown").
-define(NS_AGENTS,          						"jabber:iq:agents").
-define(NS_AMP,        									"http://jabber.org/protocol/amp").
-define(NS_AMP_ERRORS,                  "http://jabber.org/protocol/amp#errors").
-define(NS_AUTH,             						"jabber:iq:auth").
-define(NS_AVATAR,           						"jabber:iq:avatar").
-define(NS_BIND,             						"urn:ietf:params:xml:ns:xmpp-bind").
-define(NS_BOOKMARK,         						"storage:bookmarks").
-define(NS_BROWSE,           						"jabber:iq:browse").
-define(NS_BYTESTREAM,       						"http://jabber.org/protocol/bytestreams").
-define(NS_CAPS,             						"http://jabber.org/protocol/caps").
-define(NS_CHATSTATES,      						"http://jabber.org/protocol/chatstates").
-define(NS_CLIENT,          						"jabber:client").
-define(NS_COMMANDS,        						"http://jabber.org/protocol/commands").
-define(NS_COMPONENT_ACCEPT,						"jabber:component:accept").
-define(NS_COMPONENT_1,     						"http://jabberd.jabberstudio.org/ns/component/1.0").
-define(NS_COMPRESS_FEATURE,					  "http://jabber.org/features/compress").
-define(NS_COMPRESS,					          "http://jabber.org/protocol/compress").
-define(NS_DATA,   						          "jabber:x:data").
-define(NS_DELAY,          						  "jabber:x:delay").
-define(NS_DELAY_URN,                   "urn:xmpp:delay").
-define(NS_DIALBACK,    						    "jabber:server:dialback").
-define(NS_DISCO,     					        "http://jabber.org/protocol/disco").
-define(NS_DISCO_INFO,                  "http://jabber.org/protocol/disco#info").
-define(NS_DISCO_ITEMS,                 "http://jabber.org/protocol/disco#items").
-define(NS_DTCP,												"jabber:iq:dtcp").
-define(NS_ENCRYPTED,  						      "jabber:x:encrypted").
-define(NS_EVENT,      						      "jabber:x:event").
-define(NS_FEATURE,  						        "http://jabber.org/protocol/feature-neg").
-define(NS_FILE,       						      "http://jabber.org/protocol/si/profile/file-transfer").
-define(NS_FILEXFER,										"jabber:iq:filexfer").
-define(NS_GATEWAY,    						      "jabber:iq:gateway").
-define(NS_GEOLOC, 						          "http://jabber.org/protocol/geoloc").
-define(NS_GROUPCHAT,   					      "gc-1.0").
-define(NS_HTTP_BIND,						        "http://jabber.org/protocol/httpbind").
-define(NS_IBB,    						          "http://jabber.org/protocol/ibb").
-define(NS_INVISIBLE,  						      "presence-invisible").
-define(NS_IQ,      					          "iq").
-define(NS_IQ_IBB,      					      "http://jabber.org/protocol/iqibb").
-define(NS_JIDLINK,											"jabber:iq:jidlink").
-define(NS_LAST,        					      "jabber:iq:last").
-define(NS_MESSAGE,  						        "message").
-define(NS_MOOD,      					        "http://jabber.org/protocol/mood").
-define(NS_MUC,      						        "http://jabber.org/protocol/muc").
-define(NS_MUC_ADMIN,                   "http://jabber.org/protocol/muc#admin").
-define(NS_MUC_OWNER,                   "http://jabber.org/protocol/muc#owner").
-define(NS_MUC_UNIQUE,                  "http://jabber.org/protocol/muc#unique").
-define(NS_MUC_USER,                    "http://jabber.org/protocol/muc#user").
-define(NS_MUC_REGISTER,                "http://jabber.org/protocol/muc#register").
-define(NS_MUC_REQUEST,                 "http://jabber.org/protocol/muc#request").
-define(NS_MUC_ROOMCONFIG,              "http://jabber.org/protocol/muc#roomconfig").
-define(NS_MUC_ROOMINFO,                "http://jabber.org/protocol/muc#roominfo").
-define(NS_MUC_ROOMS,                   "http://jabber.org/protocol/muc#rooms").
-define(NS_MUC_TRAFIC,                  "http://jabber.org/protocol/muc#traffic").
-define(NS_NEGOTIATE,										"jabber:iq:negotiate").
-define(NS_OOB,													"jabber:iq:oob").
-define(NS_OFFLINE,        						  "http://jabber.org/protocol/offline").
-define(NS_PHYSLOC,       					    "http://jabber.org/protocol/physloc").
-define(NS_PING,					              "urn:xmpp:ping").
-define(NS_PRESENCE,       						  "presence").
-define(NS_PRIVACY,						          "jabber:iq:privacy").
-define(NS_PRIVATE,    						      "jabber:iq:private").
-define(NS_PUBSUB,    					        "http://jabber.org/protocol/pubsub").
-define(NS_REGISTER,  					        "jabber:iq:register").
-define(NS_ROSTER,       						    "jabber:iq:roster").
-define(NS_ROSTERX,     					      "http://jabber.org/protocol/rosterx").
-define(NS_RPC,       					        "jabber:iq:rpc").
-define(NS_SASL,       						      "urn:ietf:params:xml:ns:xmpp-sasl").
-define(NS_SEARCH,     						      "jabber:iq:search").
-define(NS_SERVER,   					          "jabber:server").
-define(NS_SESSION,   					        "urn:ietf:params:xml:ns:xmpp-session").
-define(NS_SI,           					      "http://jabber.org/protocol/si").
-define(NS_SI_PUB,					            "http://jabber.org/protocol/sipub").
-define(NS_SIGNED,         						  "jabber:x:signed").
-define(NS_STANZAS,     					      "urn:ietf:params:xml:ns:xmpp-stanzas").
-define(NS_STATS,                       "http://jabber.org/protocol/stats").
-define(NS_STREAMS,    						      "http://etherx.jabber.org/streams").
-define(NS_TIME,         						    "jabber:iq:time").
-define(NS_TIME_2,  						        "urn:xmpp:time").
-define(NS_TLS,           					    "urn:ietf:params:xml:ns:xmpp-tls").
-define(NS_VACATION,  					        "http://jabber.org/protocol/vacation").
-define(NS_VCARD,       					      "vcard-temp").
-define(NS_VERSION,       					    "jabber:iq:version").
-define(NS_WAITINGLIST,     					  "http://jabber.org/protocol/waitinglist").
-define(NS_XHTML_IM,     						    "http://jabber.org/protocol/xhtml-im").
-define(NS_DATA_LAYOUT,  						    "http://jabber.org/protocol/xdata-layout").
-define(NS_DATA_VALIDATE,  						  "http://jabber.org/protocol/xdata-validate").
-define(NS_XMPP_STREAMS,   						  "urn:ietf:params:xml:ns:xmpp-streams").

%%% errors ====================================================================

-define(ERR_STREAMS,[
              {"bad-format","The entity has sent XML that cannot be processed."},
              {"bad-namespace-prefix","The entity has sent a namespace prefix that is unsupported, or has sent no namespace prefix on an element that requires such a prefix."},
              {"conflict","The server is closing the active stream for this entity because a new stream has been initiated that conflicts with the existing stream."},
              {"connection-timeout","The entity has not generated any traffic over the stream for some period of time."},
              {"host-gone","The value of the 'to' attribute provided by the initiating entity in the stream header corresponds to a hostname that is no longer hosted by the server."},
              {"host-unknown","The value of the 'to' attribute provided by the initiating entity in the stream header does not correspond to a hostname that is hosted by the server."},
              {"improper-addressing","A stanza sent between two servers lacks a 'to' or 'from' attribute (or the attribute has no value)."},
              {"internal-server-error","The server has experienced a misconfiguration or an otherwise-undefined internal error that prevents it from servicing the stream."},
              {"invalid-from","The JID or hostname provided in a 'from' address does not match an authorized JID or validated domain negotiated between servers via SASL or dialback, or between a client and a server via authentication and resource authorization."},
              {"invalid-id","The stream ID or dialback ID is invalid or does not match an ID previously provided."},
              {"invalid-namespace","The streams namespace name is something other than 'http://etherx.jabber.org/streams' or the dialback namespace name is something other than 'jabber:server:dialback'."},
              {"invalid-xml","The entity has sent invalid XML over the stream to a server that performs validation."},
              {"not-authorized","The entity has attempted to send data before the stream has been authenticated, or otherwise is not authorized to perform an action related to stream negotiation."},
              {"policy-violation","The entity has violated some local service policy."},
              {"remote-connection-failed","The server is unable to properly connect to a remote resource that is required for authentication or authorization."},
              {"resource-constraint","The server lacks the system resources necessary to service the stream."},
              {"restricted-xml","The entity has attempted to send restricted XML features such as a comment, processing instruction, DTD, entity reference, or unescaped character."},
              {"see-other-host","The server will not provide service to the initiating entity but is redirecting traffic to another host."},
              {"system-shutdown","The server is being shut down and all active streams are being closed."},
              {"undefined-condition","The error condition is not one of those defined by the other conditions in this list."},
              {"unsupported-encoding","The initiating entity has encoded the stream in an encoding that is not supported by the server."},
              {"unsupported-stanza-type","The initiating entity has sent a first-level child of the stream that is not supported by the server."},
              {"unsupported-version","The value of the 'version' attribute provided by the initiating entity in the stream header specifies a version of XMPP that is not supported by the server."},
              {"xml-not-well-formed","The initiating entity has sent XML that is not well-formed."}]).

-define(ERR_STANZA,[
              {"bad-request","400","modify","The sender has sent XML that is malformed or that cannot be processed."},
              {"conflict","409","cancel","Access cannot be granted because an existing resource or session exists with the same name or address."},
              {"feature-not-implemented","501","cancel","The feature requested is not implemented by the recipient or server and therefore cannot be processed."},
              {"forbidden","403","auth","The requesting entity does not possess the required permissions to perform the action."},
              {"gone","302","modify","The recipient or server can no longer be contacted at this address."},
              {"internal-server-error","500","wait","The server could not process the stanza because of a misconfiguration or an otherwise-undefined internal server error."},
              {"item-not-found","404","cancel","The addressed JID or item requested cannot be found."},
              {"jid-malformed","400","modify","The value of the 'to' attribute in the sender's stanza does not adhere to the syntax defined in Addressing Scheme."},
              {"not-acceptable","406","cancel","The recipient or server understands the request but is refusing to process it because it does not meet criteria defined by the recipient or server."},
              {"not-allowed","405","cancel","The recipient or server does not allow any entity to perform the action."},
              {"not-authorized","401","auth","The sender must provide proper credentials before being allowed to perform the action, or has provided improper credentials."},
              {"payment-required","402","auth","The requesting entity is not authorized to access the requested service because payment is required."},
              {"recipient-unavailable","404","wait","The intended recipient is temporarily unavailable."},
              {"redirect","302","modify","The recipient or server is redirecting requests for this information to another entity."},
              {"registration-required","407","auth","The requesting entity is not authorized to access the requested service because registration is required."},
              {"remote-server-not-found","404","cancel","A remote server or service specified as part or all of the JID of the intended recipient does not exist."},
              {"remote-server-timeout","504","wait","A remote server or service specified as part or all of the JID of the intended recipient could not be contacted within a reasonable amount of time."},
              {"resource-constraint","500","wait","The server or recipient lacks the system resources necessary to service the request."},
              {"service-unavailable","503","cancel","The server or recipient does not currently provide the requested service."},
              {"subscription-required","407","auth","The requesting entity is not authorized to access the requested service because a subscription is required."},
              {"undefined-condition","500","",""},
              {"unexpected-request","400","wait","The recipient or server understood the request but was not expecting it at this time (e.g., the request was out of order)."}]).

-define(ERR_SASL,[
              {"aborted","The receiving entity acknowledges an <abort/> element sent by the initiating entity; sent in reply to the <abort/> element."},
              {"incorrect-encoding","The data provided by the initiating entity could not be processed because the [BASE64]Josefsson, S., The Base16, Base32, and Base64 Data Encodings, July 2003. encoding is incorrect (e.g., because the encoding does not adhere to the definition in Section 3 of [BASE64]Josefsson, S., The Base16, Base32, and Base64 Data Encodings, July 2003.); sent in reply to a <response/> element or an <auth/> element with initial response data."},
              {"invalid-authzid","The authzid provided by the initiating entity is invalid, either because it is incorrectly formatted or because the initiating entity does not have permissions to authorize that ID; sent in reply to a <response/> element or an <auth/> element with initial response data."},
              {"invalid-mechanism","The initiating entity did not provide a mechanism or requested a mechanism that is not supported by the receiving entity; sent in reply to an <auth/> element."},
              {"mechanism-too-weak","The mechanism requested by the initiating entity is weaker than server policy permits for that initiating entity; sent in reply to a <response/> element or an <auth/> element with initial response data."},
              {"not-authorized","The authentication failed because the initiating entity did not provide valid credentials (this includes but is not limited to the case of an unknown username); sent in reply to a <response/> element or an <auth/> element with initial response data."},
              {"temporary-auth-failure","The authentication failed because of a temporary error condition within the receiving entity; sent in reply to an <auth/> element or <response/> element."}]).
